package zuoye;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

public class MulticasSocketDemo {
    public static void main(String[] args) throws IOException {
        MulticastSocket ms = new MulticastSocket(1023);
        byte[] bys = new byte[100];
        ms.joinGroup(InetAddress.getByName("230.0.0.1"));
        DatagramPacket dp = new DatagramPacket(bys,bys.length);
        ms.receive(dp);
        System.out.println("数据是："+new String(dp.getData(),0,dp.getLength()));
        ms.close();
    }
}